package org.admanager.acme.plugin.diagram.part;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.admanager.acme.plugin.diagram.providers.AcmeADManagementMetamodelElementTypes;
import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class AcmeADManagementMetamodelPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createAcmeElement1Group());
		paletteRoot.add(createCBAConnector2Group());
	}

	/**
	 * Creates "Acme Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createAcmeElement1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.AcmeElement1Group_title);
		paletteContainer.setId("createAcmeElement1Group"); //$NON-NLS-1$
		paletteContainer.add(createComponent1CreationTool());
		paletteContainer.add(createConnector2CreationTool());
		paletteContainer.add(createPort3CreationTool());
		paletteContainer.add(createRole4CreationTool());
		paletteContainer.add(createRepresentation5CreationTool());
		paletteContainer.add(createSystem6CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "CBA Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createCBAConnector2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.CBAConnector2Group_title);
		paletteContainer.setId("createCBAConnector2Group"); //$NON-NLS-1$
		paletteContainer.add(createAttachment1CreationTool());
		paletteContainer.add(createBinding2CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponent1CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(AcmeADManagementMetamodelElementTypes.Component_3004);
		types.add(AcmeADManagementMetamodelElementTypes.Component_2002);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Component1CreationTool_title,
				Messages.Component1CreationTool_desc, types);
		entry.setId("createComponent1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.Component_3004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnector2CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(AcmeADManagementMetamodelElementTypes.Connector_2001);
		types.add(AcmeADManagementMetamodelElementTypes.Connector_3006);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Connector2CreationTool_title,
				Messages.Connector2CreationTool_desc, types);
		entry.setId("createConnector2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.Connector_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPort3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Port3CreationTool_title,
				Messages.Port3CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.Port_3005));
		entry.setId("createPort3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.Port_3005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRole4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Role4CreationTool_title,
				Messages.Role4CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.Role_3001));
		entry.setId("createRole4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.Role_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRepresentation5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Representation5CreationTool_title,
				Messages.Representation5CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.Representation_3002));
		entry.setId("createRepresentation5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.Representation_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSystem6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.System6CreationTool_title,
				Messages.System6CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.System_3003));
		entry.setId("createSystem6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelElementTypes
				.getImageDescriptor(AcmeADManagementMetamodelElementTypes.System_3003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createAttachment1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Attachment1CreationTool_title,
				Messages.Attachment1CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.Attachment_4001));
		entry.setId("createAttachment1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soadmanagement.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(AcmeADManagementMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soadmanagement.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createBinding2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Binding2CreationTool_title,
				Messages.Binding2CreationTool_desc,
				Collections
						.singletonList(AcmeADManagementMetamodelElementTypes.Binding_4002));
		entry.setId("createBinding2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(AcmeADManagementMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soadmanagement.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(AcmeADManagementMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soadmanagement.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
